<template>
	<!-- 工单详情审核 -->
	<div>
		<div class="edit-top">
			审核信息
			<i class="el-icon-close" @click='cancel'></i>
		</div>
		<div class="edit-content">
			<div class="edit-title">工单信息</div>
			<div class="edit-item">
				<label>工单标题</label><input v-model="info.title" disabled="disabled" type="text" />
			</div>
			<div class="edit-item">
				<label>工单类型</label><select v-model="info.type" disabled="disabled">
					<option v-for='item in dict.type' :value="item.value">{{item.type}}</option>
				</select>
			</div>
			<div class="edit-item">
				<label>工单状态</label><select v-model="info.status" disabled="disabled">
					<option v-for='item in dict.status' :value="item.value">{{item.type}}</option>
				</select>
			</div>
			<div class="edit-item">
				<label style="float: left;">工单内容</label><textarea disabled="disabled" v-model="info.content" rows="6" />
				</div>
			<div class="edit-item" v-if="info.status == 5">
				<label style="float: left;">评价分数</label><el-rate style="float: left;margin-top: 10px;" disabled="disabled" v-model="workCommentEntity.star"></el-rate>
			</div>
			<div class="edit-item" style="clear: both;" v-if="info.status == 5">
				<label style="float: left;">评价内容</label><textarea  disabled="disabled" v-model="workCommentEntity.content" rows="6"/>
			</div>

		</div>
		<div class="edit-bottom" v-if="flag != 1">
			<el-button @click='save(1)' type="primary">同意</el-button>
			<el-button @click='save(2)' type="info">拒绝</el-button>
			<el-button @click='save(0)' type="info">关闭</el-button>
		</div>
	</div>
</template>

<script>
	import Global from '@/components/Global.vue'
	export default {
		props: ['id','flag'],
		data() {
			return {
				dict: '',
				info: {
					title: '',
					type: 0,
					content: '',
				},
				workCommentEntity:'',
				processId: ''
			}
		},
		mounted() {
			this.get_dict();
			this.get_info();
		},
		methods: {
			get_dict() {
				var self = this;
				this.$axios.get(this.$global.serverIp + 'admin/dict/findDict?keyword=work')
				  .then(function (res) {
					  if(res != '')
						self.dict = res.data;
				  })
			},
			get_info() {
				var self = this;
				this.$axios.get(this.$global.serverIp + 'work/workform/detail/' + this.id)
					.then(function(res) {
						if (res != ''){
							self.info = res.data.object;
							self.processId = res.data.processId;
							if(self.info.status == 5){
								self.workCommentEntity = res.data.object.workCommentEntity;
							}
						}
					})
			},
			save(status) {
				var self = this;
				this.$axios.post(this.$global.serverIp + 'work/workform/nextStep', {
				"id": self.id,
				"processId": self.processId,
				"status": status
				  })
				  .then(function (res) {
					  if(res != ''){
						 self.success('审核成功');
					  }
						
				  })
				
			},
			success(content) {
				var self = this;
				this.$alert(content, '提示', {
					confirmButtonText: '确定',
					callback: action => {
						self.$emit("saveEdit", 2);
					}
				});
			},
			cancel() {
				this.$emit("saveEdit", 1);
			}
		}
	}
	import '@/assets/css/edit.css'
</script>
